<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;

class ProjectModel extends Model
{
    public $timestamps = false;
    //
    function projects(){
        $this->hasone(User::class);
    }
    public function getProject($id){
//        var_dump($id);
        if($id>0){
          return  DB::table('project_models')->where('id',$id)->get()->first();
            
        }
        else{
            return false;
        }
    }

      public function getProjectbyManager($id){
//        var_dump($id);
        if($id>0){
          return  DB::table('project_models')->where('assignerid',$id)->get()->first();
            
        }
        else{
            return false;
        }
    }

    public function getManager($id){
//        var_dump($id);
        if($id>0){
          return  DB::table('admin_users')->where('id',$id)->get()->first();
            
        }
        else{
            return false;
        }
    }
    
    public function getProjectNames(){
         $oList =  DB::table('project_models')->get();
           $aList = array();
           foreach($oList as $oOne){
               $aList[$oOne->id] = $oOne->projectname;
           }
           return $aList;
    }
    
    public function getManagerNames($id=0){
        if($id>0){
          $oList =  DB::table('admin_users')->get();
           $aList = array();
           foreach($oList as $oOne){
               $aList[$oOne->id] = $oOne->name;
           }
//           var_dump($aList);
           return $aList;
        }
        else{
            return false;
        }
    }
}
